import sequelize from "sequelize";
import db from "../database";

const user = db.define(
  "users",
  {
    id: {
      type: sequelize.INTEGER, //int类型
      autoIncrement: true, //自增
      allowNull: false, //不为空
      field: "id", //表映射
      primaryKey: true,
    },
    username: {
      type: sequelize.STRING(100), //字符串类型
      allowNull: false, //不为空
      field: "username", //表映射
    },
    password: {
      //密码
      type: sequelize.STRING(100),
      allowNull: false,
      field: "password",
    },
    phone: {
      type: sequelize.STRING(11),
      allowNull: false,
      field: "phone",
    },
    points: {
      type: sequelize.DECIMAL(10, 2),
      allowNull: false,
      field: "points",
      defaultValue: 0,
    },
  },
  { timestamps: true }
);
export default user;
